#!/usr/bin/env python
# encoding: utf-8
'''
@author: zhaowenpeng
@contact: winston@peipeiyun.com
@software: garner
@file: fetch_code_oe.py
@time: 2020/8/11 2:44 下午
@desc:
'''

import sys
# sys.path.append('../../')

import os
import pandas as pd
import numpy

import time


from models.audi.cars_audi import CarsAudiNew
for root,p,files in os.walk('/Users/liuchong/standartools/cars_scripts/audi/export'):
    for fi in files:
        fi ='/'.join([root,fi])
        df = pd.read_csv(fi)
        df.fillna('',inplace=True)
        df['pid'] = df['pid'].astype('str')
        for index, row in df.iterrows():
            audi = CarsAudiNew()
            audi.pid = row.to_dict()['pid']
            audi.standard_label = row.to_dict()['standard_label']
            audi.label = row.to_dict()['label']
            audi.desc = row.to_dict()['desc']
            audi.engine_code = row.to_dict()['engine_code']
            audi.cylinder = row.to_dict()['cylinder']
            audi.transmission = row.to_dict()['transmission']
            audi.trans_desc = row.to_dict()['trans_desc']
            audi.replace = row.to_dict()['replace']
            audi.drive = row.to_dict()['drive']
            audi.diff_mech = row.to_dict()['差速器']
            audi.displacement = row.to_dict()['displacement']
            audi.brand_code = row.to_dict()['brandCode']
            audi.drive_new = row.to_dict()['drive_new']
            audi.save()


